import { createRouter, createWebHistory } from 'vue-router'

export default createRouter({
  // 路由模式
  history: createWebHistory(),
  // 路由管理
  routes: [
    {
      path: '/home',
      name: 'Home',
      component: () => import(/* webpackChunkName: "home" */ '@/pages/home/index.vue')
    },
    {
      path: '/hospital',
      name: 'hospital',
      component: () => import(/* webpackChunkName: "hospital" */ '@/pages/hospital/index.vue'),
      children: [
        {
          path: 'register',
          name: 'Register',
          component: () =>
            import(/* webpackChunkName: "list" */ '@/pages/hospital/register/index.vue')
        },
        {
          path: 'detail',
          name: 'Detail',
          component: () =>
            import(/* webpackChunkName: "detail" */ '@/pages/hospital/detail/index.vue')
        },
        {
          path: 'notice',
          name: 'Notice',
          component: () =>
            import(/* webpackChunkName: "detail" */ '@/pages/hospital/notice/index.vue')
        },
        {
          path: 'close',
          name: 'Close',
          component: () =>
            import(/* webpackChunkName: "detail" */ '@/pages/hospital/close/index.vue')
        },
        {
          path: 'search',
          name: 'Search',
          component: () =>
            import(/* webpackChunkName: "detail" */ '@/pages/hospital/search/index.vue')
        },
        {
          path: 'register_step1/:depcode',
          name: 'Step1',
          props: true,
          component: () =>
            import(/* webpackChunkName: "detail" */ '@/pages/hospital/register/register_step1.vue')
        },
        {
          path: 'register_step2/:scheduleId',
          name: 'Step2',
          props: true,
          component: () =>
            import(/* webpackChunkName: "detail" */ '@/pages/hospital/register/register_step2.vue')
        }
      ]
    },
    {
      path: '/user',
      name: 'User',
      component: () => import(/* webpackChunkName: "home" */ '@/pages/user/index.vue'),
      children: [
        {
          path: 'order',
          name: 'Order',
          component: () => import(/* webpackChunkName: "home" */ '@/pages/user/order/index.vue')
        },
        {
          path: 'feedback',
          name: 'Feedback',
          component: () => import(/* webpackChunkName: "home" */ '@/pages/user/feedback/index.vue')
        },
        {
          path: 'profile',
          name: 'Profile',
          component: () => import(/* webpackChunkName: "home" */ '@/pages/user/profile/index.vue')
        },
        {
          path: 'patient',
          name: 'Patient',
          component: () => import(/* webpackChunkName: "home" */ '@/pages/user/patient/index.vue')
        },
        {
          path: 'auth',
          name: 'Auth',
          component: () => import(/* webpackChunkName: "home" */ '@/pages/user/auth/index.vue')
        }
      ]
    },
    {
      path: '/',
      name: 'Index',
      redirect: '/home'
    }
  ],
  // 滚动行为: 控制滚动条的位置
  scrollBehavior() {
    return {
      top: 0,
      left: 0
    }
  }
})
